﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace CheckOilPrices.HelperClasses
{
    public class FBWallBJPost
    {
        public string TheCaption { get; set; }
        public string TheDescription { get; set; }
        public string TheLink { get; set; }
        public string TheMessage { get; set; }
        public string TheName { get; set; }
        public string ThePictureLink { get; set; }

        public FBWallBJPost() { }
        public FBWallBJPost(bool bFillDefaults)
        {
            if (bFillDefaults)
            {
                //TheCaption = "";
                //TheDescription = "Testdescription";
                TheLink = "http://www.bangchak.co.th/th/";
                TheMessage = "Message sented by CheckOilPrice Application from Window Phone 7";
                TheName = "Bangchak Oil";
                ThePictureLink = "http://www.thairath.co.th/media/content/2010/08/21/105278/hr1667/630.jpg";
            }
        }


        public string GetPostParameters(string strAccessToken, string TheCaption, string p1, string p2, string p3, string p4, string p5, string p6, string p7, string p8)
        {
            if (p1==null)
            {
                TheDescription = "SuperPowerD = " + p2 + "\n" + "GasoholE85 = " + p3 + "\n" + "GasoholE20 = " + p4 + "\n" + "Gasohol91 = " + p5 + "\n" + "Gasohol95 = " + p6 + "\n" + "GreenPlus91 = " + p7 + "\n" + "NGV = " + p8;
            }
            else
            {
                TheDescription = "SuperPowerB5 = " + p1 + "\n" + "SuperPowerD = " + p2 + "\n" + "GasoholE85 = " + p3 + "\n" + "GasoholE20 = " + p4 + "\n" + "Gasohol91 = " + p5 + "\n" + "Gasohol95 = " + p6 + "\n" + "GreenPlus91 = " + p7 + "\n" + "NGV = " + p8;
            }

            try
            {
                string strRet = "access_token=" + strAccessToken;
                if (!string.IsNullOrEmpty(TheCaption))
                {
                    strRet += "&caption=" + HttpUtility.UrlEncode(DateTime.Now.ToString());
                }
                if (!string.IsNullOrEmpty(TheDescription))
                {
                    strRet += "&description=" + HttpUtility.UrlEncode(TheDescription);
                }
                if (!string.IsNullOrEmpty(TheLink))
                {
                    strRet += "&link=" + HttpUtility.UrlEncode(TheLink);
                }
                if (!string.IsNullOrEmpty(TheMessage))
                {
                    strRet += "&message=" + HttpUtility.UrlEncode("ราคาน้ำมันปั้ม บางจาก " + TheCaption);
                }
                if (!string.IsNullOrEmpty(TheName))
                {
                    strRet += "&name=" + HttpUtility.UrlEncode(TheName);
                }
                if (!string.IsNullOrEmpty(ThePictureLink))
                {
                    strRet += "&picture=" + HttpUtility.UrlEncode(ThePictureLink);
                }
                return (strRet);
            }
            catch { return (""); }
        }
    }
}
